<%@ include file="/en/jsp/static.jsp" %>
<%@ taglib uri="/linuxbox/common.tld" prefix="Common" %>

<jsp:include page="/en/jsp/header.jsp" flush="true"/>
<table width="100%" border=0 cellpadding=0 cellspacing=0>
<tr><td>

<script Language="JavaScript">
  function confirmDel(entry)
	{
	  return confirm("Are you sure to delete " + entry);
  }
</script>

<table width="100%" height=26 align=middle border=0 cellpadding=0 cellspacing=0 bgcolor="#f4f4f4" style="font-size:16px;color:#d05000">
<tr><td>
	  &nbsp;<img src="<%=imageDir%>/itemball.jpg" width=14 height=15 border=0 align="absmiddle">
	  <b><%=boxName%> - Resource Category Management</b>
</td></tr>
</table>
<br>



<FORM action="<%=servletDir%>/BoxResourceCatAction" method="POST">
  <input type="submit" name="SubmitEdit" value="Add a Resource Category">

	<jsp:useBean id="home" class="linuxbox.resource.logic.BoxResourceCat"/>
	<jsp:useBean id="resource" class="linuxbox.resource.logic.BoxResource"/>

  <TABLE cellSpacing=1 cellPadding=1 width="100%" border=0 bgColor=#dddddd>
    <TR>
      <TH bgColor=#b9daf5 width="20%">Name</TH>
      <TH bgColor=#b9daf5  width="1%">Delete</TH>
      <TH bgColor=#b9daf5>Description</TH>
      <TH bgColor=#b9daf5 width="15%">Resource Count</TH>
    </TR>
<%
  java.util.Iterator it = home.getAllCategories();
  if ( it != null && it.hasNext())
  {
%>
    <Common:Iteration name="entry" type="linuxbox.resource.logic.BoxResourceCatEntry" group="<%=it%>">
      <TR>
<%
  int count = resource.getResourceCountByCat(entry.getID());
%>
        <TD bgColor=#eeeeee><a href="<%=servletDir%>/BoxResourceCatAction?ID=<%=entry.getID()%>&SubmitEdit=edit"><%=entry.getName()%></a></TD>
        <TD bgColor=#eeeeee>
<%
  if (count == 0 )
  {
%>
          <a href="<%=servletDir%>/BoxResourceCatAction?SubmitDelete=del&ID=<%=entry.getID()%>" Onclick='return confirmDel("<%=entry.getName()%>")'>Delete</a>
<%
  }
%>
        </TD>
        <TD bgColor=#eeeeee><%=entry.getDescription()%></TD>
        <TD bgColor=#eeeeee align=center><a href="<%=servletDir%>/BoxResourceAction?SubmitSort=view&SORTBY=category" ALT="View resources"><%=count%></a></TD>
      </TR>
    </Common:Iteration>
<%
  }
%>
  </TABLE>
</FORM>

</td></tr>
</table>
<jsp:include page="/en/jsp/footer.jsp" flush="true"/>
